using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Net;

namespace Krile.Kernel.Bridges
{
    /// <summary>
    /// Image callback delegate
    /// </summary>
    /// <param name="uri">target uri</param>
    /// <param name="image">downloaded image(you should dispose image object after use it)</param>
    public delegate void GetImageCallbackDelegate(Uri uri, Image image);

    /// <summary>
    /// Credential callbacks
    /// </summary>
    /// <param name="uri">target uri</param>
    /// <returns>if you serve credential,you should return ICredential instance.Else,you may returns null.</returns>
    public delegate ICredentials GetCredentialCallbackDelegate(Uri uri);

    public interface IImageManager
    {
        /// <summary>
        /// Get image(you should dispose image object after use it)
        /// </summary>
        /// <param name="uri">target uri</param>
        /// <param name="refresh">re-download picture</param>
        Image GetImage(Uri uri, bool refresh);

        /// <summary>
        /// Get image with another thread and using callback
        /// </summary>
        /// <param name="uri">target uri</param>
        /// <param name="refresh">re-download picture</param>
        /// <param name="callback">callback method's delegate</param>
        void GetImageCallback(Uri uri, bool refresh, GetImageCallbackDelegate callback);

        /// <summary>
        /// Make download image reservation
        /// </summary>
        /// <param name="uri">target uri</param>
        /// <param name="refresh">re-download picture</param>
        void ReserveImage(Uri uri, bool refresh);

        /// <summary>
        /// Check cache exists
        /// </summary>
        /// <param name="uri">target uri</param>
        /// <returns>When exists cache ,return true. Else,returns false.</returns>
        bool IsCacheExists(Uri uri);

        /// <summary>
        /// Destroy image cache
        /// </summary>
        /// <param name="uri">target uri</param>
        void DestroyCache(Uri uri);

        /// <summary>
        /// Check download image is reserved
        /// </summary>
        /// <param name="uri">target</param>
        bool IsReserved(Uri uri);

        /// <summary>
        /// Add method in CredentialCallbackList
        /// </summary>
        /// <param name="credcback">callback method's delegate</param>
        void AddCredentialCallbackList(GetCredentialCallbackDelegate credcback);
    }
}
